package com.qst.survey.controller;


import com.qst.survey.entity.Type;
import com.qst.survey.pojo.Result;
import com.qst.survey.pojo.StatusCode;
import com.qst.survey.service.TypeService;
import com.qst.survey.util.NoAuthorization;
import com.qst.survey.vo.BarVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.io.Serializable;
import java.util.List;

/**
 * @Auther: IsAriel~~
 * @Date: 2021/3/21 14:27
 * @Description: 类型控制类
 */

@RestController
@RequestMapping("/type")
@CrossOrigin
public class TypeController {

    @Autowired
    TypeService typeService;
    /**
     * @description  TODO 查出所有的类型
     * @return com.qst.survey.pojo.Result
     * @date 2021/4/2
    */
    @NoAuthorization
    @GetMapping("/all")
    public Result findAll() {
        return new Result(true, StatusCode.OK, "查询成功!",typeService.findAll());
    }
    /**
     * @description  TODO   返回一个柱状图数据
     * @return com.qst.survey.pojo.Result
     * @date 2021/4/2
    */
    @GetMapping("/getBar")
    public Result getBar(){
        BarVO barVo=typeService.getBar();
        return new Result(true, StatusCode.OK, "查询成功!",barVo);
    }
}
